package com.atguigu.study.controller;

import dev.langchain4j.model.chat.ChatLanguageModel;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @auther zzyy
 * @create 2025-03-11 17:47
 */
@RestController
@Slf4j
public class ChatLanguageModelController {
    @Resource
    private ChatLanguageModel chatLanguageModel;


    /**
     * 测试langchain4j的常用配置
     * 1，日志界别设置
     * 2，超时设置
     * 3，重试机制
     * 请求地址：http://localhost:9003/chatconfig/config
     * @param prompt
     * @return
     */
    @GetMapping(value = "/chatconfig/config")
    public String hello(@RequestParam(value = "prompt", defaultValue = "你是谁") String prompt) {
        return chatLanguageModel.generate(prompt);
    }
}
